<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>对象继承</title>
</head>

<body>

</body>
<script type="text/javascript">
    //手机构造函数
    function Phone(brand, price){
        //为实例对象添加属性
        this.brand = brand;
        this.price = price;
    }

    //声明方法
    Phone.prototype.dianhua = function(){
        console.log('可以打电话');
    }

    //智能手机
    function SmartPhone(brand, price, storage, pixel){
        //初始化
        Phone.call(this, brand, price);
        //存储空间和像素的初始化
        this.storage = storage;
        this.pixel = pixel;
    }

    //继承
    SmartPhone.prototype = new Phone();
    SmartPhone.prototype.constructor = SmartPhone;

    //添加方法
    SmartPhone.prototype.photo = function(){
        console.log('可以拍照哦~~~');
    }
    SmartPhone.prototype.chat = function(){
        console.log('可以聊天哦~~');
    }

    //实例化
    let vivo = new SmartPhone('vivo', 4999, '256G', '100000000')

    console.log(vivo);


</script>

</html>